#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time : 2021/9/12 14:28
# @Author : lenovo
# @Email : 26541796406@qq.com
# @File : task_page.py
# @Project : crm
"""任务信息页面"""
from selenium.webdriver.common.by import By
from page.base_page import BasePage
from utils.util import HS3
class Task(BasePage):
    """任务首页类，一系列元素，以及操作"""
    url = "{}/crm3/index.php?m=task".format(HS3)
    """定义定位器"""
    amending_locator = (By.LINK_TEXT, '修改')  # 修改任务键
    new_locator = (By.XPATH, '/html/body/div[5]/div[2]/div[1]/div/a')  # 新建任务按钮
    button_locator = (By.CSS_SELECTOR, 'input[name="task_id[]"]')  # 单选框input
    all_button_locator = (By.NAME, 'control_all')  # 全选框input
    delete_locator = (By.LINK_TEXT, '删除')  # 删除按钮
    get_txt_locator = (By.XPATH,'/html/body/div[5]/div[2]')  # 添加成功后的文本框
    def input1_buttton(self):
        """第一个单选框"""
        self.driver.find_elements(*self.button_locator)[0].click()
    def input2_button(self):
        """第二个单选框"""
        self.driver.find_elements(*self.button_locator)[1].click()
    def all_input_button(self):
        """全选框"""
        self.driver.find_element(*self.all_button_locator).click()
    def del_button(self):
        """删除按钮"""
        self.driver.find_element(*self.delete_locator).click()
    def new_submit(self):
        """点击添加"""
        self.driver.find_element(*self.new_locator).click()
    def amend_submit(self):
        """点击修改"""
        self.driver.find_elements(*self.amending_locator)[0].click()

